package com.qg.controller;


import com.qg.service.LocailGoodsService;
import com.qg.utils.RedisUtil;
import com.zxs.resp.ReturnResult;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/api")
@Controller
public class GoodsController {

    @Reference
    private LocailGoodsService locailGoodsService;

    @Autowired
    private RedisUtil redisUtil;



    /**
     *查询商品信息
     * @param id
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping(value = "queryGoodsById", method = RequestMethod.POST)
    public ReturnResult queryGoodsById(String id) throws Exception {
        return locailGoodsService.queryGoodsById(id);
    }

    /**
     * 抢购商品的方法
     * @param taken
     * @param goodsId
     * @return
     * @throws Exception
     */
    @ResponseBody
    @RequestMapping(value = "getGoods", method = RequestMethod.POST)
    public ReturnResult getGoods(String taken,String goodsId) throws Exception{
        return locailGoodsService.getGoods(taken,goodsId);
    }
}
